package com.xbongbong.saas.model.impl;

import com.xbongbong.paas.constant.PaasConstant;
import com.xbongbong.paas.enums.DelEnum;
import com.xbongbong.paas.toolbox.util.CollectionsUtil;
import com.xbongbong.saas.domain.dao.SmartReplenishmentDao;
import com.xbongbong.saas.domain.entity.SmartReplenishmentEntity;
import com.xbongbong.saas.model.SmartReplenishmentModel;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author bomfish
 */
@Service("smartReplenishmentModel")
public class SmartReplenishmentModelImpl implements SmartReplenishmentModel {
    @Resource
    private SmartReplenishmentDao smartReplenishmentDao;

    @Override
    public Long insert(SmartReplenishmentEntity entity) {
        return smartReplenishmentDao.insert(entity);
    }

    @Override
    public void insertBatch(List<SmartReplenishmentEntity> list) {
        smartReplenishmentDao.insertBatch(list);
    }

    @Override
    public List<SmartReplenishmentEntity> findEntitys(Map<String, Object> param) {
        return smartReplenishmentDao.findEntitys(param);
    }

    @Override
    public Integer getEntitysCount(Map<String, Object> param) {
        return smartReplenishmentDao.getEntitysCount(param);
    }

    @Override
    public void update(SmartReplenishmentEntity entity) {
        smartReplenishmentDao.update(entity);
    }

    @Override
    public SmartReplenishmentEntity getByKey(Long key, String corpid) {
        return smartReplenishmentDao.getByKey(key, corpid);
    }

    @Override
    public List<SmartReplenishmentEntity> getEnablePurchasePassage(Map<String, Object> param) {
        return smartReplenishmentDao.getEnablePurchasePassage(param);
    }

    @Override
    public List<SmartReplenishmentEntity> getEnableMiniStock(Map<String, Object> param) {
        return smartReplenishmentDao.getEnableMiniStock(param);
    }

    @Override
    public List<SmartReplenishmentEntity> getAllEnable(Map<String, Object> param) {
        return smartReplenishmentDao.getAllEnable(param);
    }

    @Override
    public List<SmartReplenishmentEntity> getAllNotEnable(Map<String, Object> param) {
        return smartReplenishmentDao.getAllNotEnable(param);
    }

    @Override
    public Integer countEnablePurchasePassage(Map<String, Object> param) {
        return smartReplenishmentDao.countEnablePurchasePassage(param);
    }

    @Override
    public Integer countEnableMiniStock(Map<String, Object> param) {
        return smartReplenishmentDao.countEnableMiniStock(param);
    }

    @Override
    public Integer countAllEnable(Map<String, Object> param) {
        return smartReplenishmentDao.countAllEnable(param);
    }

    @Override
    public Integer countAllNotEnable(Map<String, Object> param) {
        return smartReplenishmentDao.countAllNotEnable(param);
    }

    @Override
    public Integer updateBatch(List<SmartReplenishmentEntity> list, String corpid) {
        if (CollectionsUtil.isEmpty(list)) {
            return 0;
        }
        return smartReplenishmentDao.updateBatch(list, corpid);
    }

    @Override
    public SmartReplenishmentEntity getByProducId(String corpid, Long productId) {
        return smartReplenishmentDao.getByProducId(corpid, productId);
    }

    @Override
    public List<SmartReplenishmentEntity> getByProductList(String corpid,List<Long> productIdList){
        Map<String,Object> smartParam = new HashMap<>(PaasConstant.DEFAULT_INITIAL_CAPACITY);
        smartParam.put("corpid",corpid);
        smartParam.put("del", DelEnum.NORMAL.getDel());
        smartParam.put("productIdIn",productIdList);
        return smartReplenishmentDao.findEntitys(smartParam);
    }

}
